package com.yunji.order.command.retund.impl;

import com.yunji.common.model.dto.LoginInfo;
import com.yunji.common.utils.TimeUtils;
import com.yunji.order.command.retund.AbsRefundCommand;
import com.yunji.order.domain.RefundDO;
import com.yunji.order.dto.cmd.RefundCommandDTO;
import com.yunji.order.dto.cmd.RefundRejectCommandDTO;
import com.yunji.system.context.SystemContext;
import org.springframework.stereotype.Component;

/**
 * @author : peter-zhu
 * @date : 2025/3/27 15:33
 * @description : TODO
 **/
@Component
public class RefundRejectCommand extends AbsRefundCommand<RefundRejectCommandDTO, Boolean> {

    @Override
    public Boolean execute(RefundRejectCommandDTO cmd) {
        RefundDO origin = cmd.getRefundDO();
        RefundDO refundDO = new RefundDO();
        refundDO.setRefundId(origin.getRefundId());
        refundDO.setApplyStatus(cmd.getNewStatus().getCode());
        refundDO.setRejectReason(cmd.getRejectReason());
        LoginInfo user = SystemContext.getUser();
        refundDO.setAuditor(user.getUserId());
        refundDO.setAuditName(user.getRealName());
        refundDO.setAuditTime(TimeUtils.getNowDate());
        return refundService.updateRefund(refundDO);
    }

}

